cmake_minimum_required(VERSION 2.8)

project (cdocgen)

set(DEFAULT_DIST ${PROJECT_SOURCE_DIR}/dist)

file(GLOB files ${DEFAULT_DIST}/*.*)

#message(STATUS "==FILE LIST: " ${DEFAULT_DIST} ${files})

add_executable(vercdoc txt/ver.c)

set(CPACK_NSIS_MODIFY_PATH ON)

install(TARGETS vercdoc RUNTIME DESTINATION bin)
install(FILES ${files} DESTINATION bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/user DESTINATION .)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/txt DESTINATION .)
install(FILES README.txt LICENSE.txt DESTINATION .)

set(CPACK_PACKAGE_NAME cdocgen)
set(CPACK_PACKAGE_VENDOR "Smartcoder")

set(CPACK_NSIS_CONTACT "kaikuo.zhuo@hotmail.cn")

set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 3)
set(CPACK_PACKAGE_VERSION_PATCH 6)

file(READ ${CMAKE_SOURCE_DIR}/mainver.txt rline)
string(STRIP ${rline} line)

message(STATUS "VER: " ${line} "VEREND")
#set(CPACK_PACKAGE_VERSION 0.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${line})

set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/WELCOME.txt)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A smart tool for self-documatation.")

SET(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_SOURCE_DIR}/WELCOME.txt)
SET(CPACK_RESOURCE_FILE_README  ${CMAKE_SOURCE_DIR}/README.txt)
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)

set(CPACK_PACKAGE_INSTALL_DIRECTORY "cdocgen")

include(CPack)
